//
//  RotatingScannerView.swift
//  casdon_swiftUI
//
//  Created by ww on 2025/5/9.
//

import SwiftUI
import Combine

struct RotatingScannerView: View {
    let isAnimating: Bool
    let imageName: String
    let size: CGFloat

    @State private var angle: Double = 0
    private let timer = Timer.publish(every: 0.01, on: .main, in: .common).autoconnect()

    var body: some View {
        Image(imageName)
            .resizable()
            .frame(width: size, height: size)
            .rotationEffect(.degrees(angle))
            .onReceive(timer) { _ in
                guard isAnimating else { return }
                angle += 0.5
                if angle >= 360 { angle -= 360 }
            }
    }
}

